﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sub.TaskPlanningDesk.Model.Repositories;

namespace Sub.TaskPlanningDesk.Model.Services.Account
{
	public class AccountMembershipService : IMembershipService
	{
		private IUserRepository _userRepository;

		public AccountMembershipService(IUserRepository userRepository)
		{
			_userRepository = userRepository;
		}

		public bool ValidateUser(string userName, string password)
		{
			var user = _userRepository.FindUserByName(userName);
			if (user == null)
				return false;

			return user.Password == password;
		}

		public int? GetUserId(string userName)
		{
			var user = _userRepository.FindUserByName(userName);
			if (user == null)
				return null;

			return user.ID;
		}
	}
}
